<HTML>

<HEAD>
        <META NAME="keywords" CONTENT="electronic commerce, ecommerce, ebusiness, e-business, e-commerce, enterprise software, net economy, Netscape, Sun Microsystems, Sun-Netscape Alliance, iPlanet, internet software">
        <META NAME="description" CONTENT="The Sun-Netscape Alliance, a strategic alliance formed by America Online and Sun Microsystems, Inc., is delivering iPlanet e-commerce software and enterprise solutions that enable companies to compete successfully in the Net Economy">
	<META HTTP-EQUIV="Content-Type" content="text/html; charset=ISO-8859-1">
	<META NAME="TEMPLATEBASE" CONTENT="Authored in FrameMaker. Converted to HTML in WebWorks Publisher 2000. manual wdt 1.5">
	<META NAME="LASTUPDATED" CONTENT="09/28/00 13:17:55">
	<TITLE> Core JavaScript Guide 1.5: 3 Expressions and Operators</TITLE>
</HEAD>




<BODY TEXT="#000000" LINK="#666699" VLINK="#666699" ALINK="#333366" BGCOLOR="#FFFFFF">

<MAINCONTENT>

<NAVIGATIONCONTENT>
   <TABLE WIDTH="100%" BORDER="0" CELLSPACING="4">
      <TR>
         <TD VALIGN="TOP">
            <b><a href="ident.html">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Previous</a></FONT>&nbsp;&nbsp;&nbsp;&nbsp;</b>
<a href="contents.html">
<b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Contents</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="ix.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Index</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="regexp.html">
<b>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">
Next
</a>
</FONT>
</b>&nbsp;&nbsp;&nbsp;&nbsp;
         </TD>
     </TR>

      <TR>
         <TD VALIGN="TOP" ALIGN="RIGHT" BGCOLOR="#CCCCCC">
            <FONT FACE="Arial, Helvetica, sans-serif" COLOR="#000000" SIZE="2"><B>
             Core JavaScript Guide 1.5</B></FONT>
         </TD>
      </TR>
      <TR>
   </TABLE>
   <BR>
</NAVIGATIONCONTENT>

<BOOKCONTENT>
   <blockquote>
<BR>
<BR>

      <A NAME="1008300"> </A><A NAME=""> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="4" COLOR="#666666"><B>
<zchapnumber>Chapter 3 </zchapnumber>
&nbsp;
</B>
</FONT>


<A NAME="1008302"> </A>
<A NAME="Expressions and Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4" COLOR="#000000">
<B>
<zchaptitle>Expressions and Operators</zchaptitle>
</B>
</FONT>
<BR>
<BR>
<BR>

<A NAME="1008304"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>This chapter describes JavaScript expressions and operators, including assignment, comparison, arithmetic, bitwise, logical, string, and special operators.</zparagraph>
</FONT>
<P>

<A NAME="1010253"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>This chapter contains the following sections:</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1010258"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1010338"  >Expressions</A></zsmartlist1>
</FONT>
<P><A NAME="1010265"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008323"  >Operators</A></zsmartlist1>
</FONT>
<P></ul>

<BR>
<BR>

<A NAME="1010338"> </A>
<A NAME="Expressions"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead1>Expressions</zhead1>
<HR SIZE="2" NOSHADE>
</FONT>
<BR>


<A NAME="1008309"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>An <I>expression</I> is any valid set of literals, variables, operators, and expressions that evaluates to a single value; the value can be a number, a string, or a logical value.</zparagraph>
</FONT>
<P>

<A NAME="1008310"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Conceptually, there are two types of expressions: those that assign a value to a variable, and those that simply have a value. For example, the expression <FONT FACE="courier, couriernew, monospaced size">x&nbsp;=&nbsp;7</FONT> is an expression that assigns x the value seven. This expression itself evaluates to seven. Such expressions use <I>assignment operators.</I> On the other hand, the expression <FONT FACE="courier, couriernew, monospaced size">3&nbsp;+&nbsp;4</FONT> simply evaluates to seven; it does not perform an assignment. The operators used in such expressions are referred to simply as <I>operators</I>.</zparagraph>
</FONT>
<P>

<A NAME="1008314"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>JavaScript has the following types of expressions:</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1008315"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>Arithmetic: evaluates to a number, for example 3.14159</zsmartlist1>
</FONT>
<P><A NAME="1008316"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>String: evaluates to a character string, for example, "Fred" or "234"</zsmartlist1>
</FONT>
<P><A NAME="1008317"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>Logical: evaluates to true or false</zsmartlist1>
</FONT>
<P><A NAME="1013204"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>Object: evaluates to an object</zsmartlist1>
</FONT>
<P></ul>

<BR>
<BR>

<A NAME="1008323"> </A>
<A NAME="Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead1>Operators</zhead1>
<HR SIZE="2" NOSHADE>
</FONT>
<BR>


<A NAME="1010776"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>JavaScript has the following types of operators. This section describes the operators and contains information about operator precedence.</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1011543"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008336"  >Assignment Operators</A></zsmartlist1>
</FONT>
<P><A NAME="1011550"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1010037"  >Comparison Operators</A></zsmartlist1>
</FONT>
<P><A NAME="1011556"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008458"  >Arithmetic Operators</A></zsmartlist1>
</FONT>
<P><A NAME="1011557"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008505"  >Bitwise Operators</A></zsmartlist1>
</FONT>
<P><A NAME="1011558"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008622"  >Logical Operators</A></zsmartlist1>
</FONT>
<P><A NAME="1011598"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008684"  >String Operators</A></zsmartlist1>
</FONT>
<P><A NAME="1011599"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008688"  >Special Operators</A></zsmartlist1>
</FONT>
<P></ul>

<A NAME="1008325"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>JavaScript has both <I>binary</I> and <I>unary</I> operators. A binary operator requires two operands, one before the operator and one after the operator:</zparagraph>
</FONT>
<P>
<A NAME="1008326"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>operand1</I> <I>operator</I> <I>operand2
</I></zcodeline>
</FONT>
<P>
<A NAME="1008327"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For example, <FONT FACE="courier, couriernew, monospaced size">3+4</FONT> or <FONT FACE="courier, couriernew, monospaced size">x*y</FONT>.</zparagraph>
</FONT>
<P>

<A NAME="1008328"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A unary operator requires a single operand, either before or after the operator:</zparagraph>
</FONT>
<P>
<A NAME="1008329"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>operator</I> <I>operand
</I></zcodeline>
</FONT>
<P>
<A NAME="1008330"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>or</zparagraph>
</FONT>
<P>
<A NAME="1008331"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>operand</I> <I>operator
</I></zcodeline>
</FONT>
<P>
<A NAME="1008332"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For example, <FONT FACE="courier, couriernew, monospaced size">x++</FONT> or <FONT FACE="courier, couriernew, monospaced size">++x</FONT>.</zparagraph>
</FONT>
<P>

<A NAME="1008333"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>In addition, JavaScript has one ternary operator, the conditional operator. A ternary operator requires three operands.</zparagraph>
</FONT>
<P>
<P>
<BR>
<A NAME="1008336"> </A>
<A NAME="Assignment Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>Assignment Operators</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008337"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>An assignment operator assigns a value to its left operand based on the value of its right operand. The basic assignment operator is equal (=), which assigns the value of its right operand to its left operand. That is, x = y assigns the value of y to x.</zparagraph>
</FONT>
<P>

<A NAME="1009977"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The other assignment operators are shorthand for standard operations, as shown in the following table.</zparagraph>
</FONT>
<P>

<P>
<A NAME="1010046"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<BR>
<P>
<TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0">
  <CAPTION></CAPTION><P><FONT FACE=""><B>
<A NAME="1009984"> </A>
<A NAME="Assignment operators"> </A>
<ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablecaption>Table 3.1&#32;&nbsp&nbsp Assignment operators</ztablecaption>
</B>
</FONT>
</B></FONT>
<BR>
<BR>
  <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1009988"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Shorthand operator </ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1009990"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Meaning</ztablehead>
</B>
</FONT>
</TH>
  </DIV></TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011831"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x += y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009994"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x + y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011834"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x -= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009998"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x - y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011837"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x *= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1010002"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x * y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011840"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x /= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1010006"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x / y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011843"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x %= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1010010"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x % y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011846"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x &lt;&lt;= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1010014"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x &lt;&lt; y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011849"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x &gt;&gt;= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1010018"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x &gt;&gt; y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011852"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x &gt;&gt;&gt;= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1010022"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x &gt;&gt;&gt; y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011855"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x &amp;= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1010026"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x &amp; y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011858"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x ^= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1010030"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x ^ y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP><A NAME="1011861"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x |= y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1010034"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x = x | y
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
</TABLE>



<P>
</FONT>
<P>

<P>
<BR>
<A NAME="1010037"> </A>
<A NAME="Comparison Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>Comparison Operators</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008399"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A comparison operator compares its operands and returns a logical value based on whether the comparison is true. The operands can be numerical, string, logical, or object values. Strings are compared based on standard lexicographical ordering, using Unicode values. The following table describes the comparison operators.</zparagraph>
</FONT>
<P>

<P>
<A NAME="1010078"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<BR>
<P>
<TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0">
  <CAPTION></CAPTION><P><FONT FACE=""><B>
<A NAME="1008406"> </A>
<A NAME="Comparison operators"> </A>
<ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablecaption>Table 3.2&#32;&nbsp&nbsp Comparison operators</ztablecaption>
</B>
</FONT>
</B></FONT>
<BR>
<BR>
  <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008412"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Operator</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008414"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Description</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008419"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Examples returning true<A HREF="#1008418"><SUP>1</SUP></A></ztablehead>
</B>
</FONT>
</TH>
  </DIV></TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011887"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Equal (<FONT FACE="courier, couriernew, monospaced size">==</FONT>)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1009671"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns true if the operands are equal. If the two operands are not of the same type, JavaScript attempts to convert the operands to an appropriate type for the comparison.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009673"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>3 == var1<br>
"3" == var1<br>
3 == '3'
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011890"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Not equal (<FONT FACE="courier, couriernew, monospaced size">!=</FONT>)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1009677"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns true if the operands are not equal. If the two operands are not of the same type, JavaScript attempts to convert the operands to an appropriate type for the comparison.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009679"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>var1 != 4<br>
var2 != "3"
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011893"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Strict equal (<FONT FACE="courier, couriernew, monospaced size">===</FONT>)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1009683"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns true if the operands are equal and of the same type.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009685"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>3 === var1
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011896"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Strict not equal (<FONT FACE="courier, couriernew, monospaced size">!==</FONT>)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1009689"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns true if the operands are not equal and/or not of the same type.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009691"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>var1 !== "3"<br>
3 !== '3'
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011899"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Greater than (<FONT FACE="courier, couriernew, monospaced size">&gt;</FONT>)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1009695"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns true if the left operand is greater than the right operand.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009697"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>var2 &gt; var1
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011901"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Greater than or equal (<FONT FACE="courier, couriernew, monospaced size">&gt;=</FONT>)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1009701"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns true if the left operand is greater than or equal to the right operand.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009703"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>var2 &gt;= var1<br>
var1 &gt;= 3
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011905"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Less than (<FONT FACE="courier, couriernew, monospaced size">&lt;</FONT>)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1009707"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns true if the left operand is less than the right operand.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009709"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>var1 &lt; var2
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011908"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Less than or equal (<FONT FACE="courier, couriernew, monospaced size">&lt;=</FONT>)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1009713"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns true if the left operand is less than or equal to the right operand.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1009715"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>var1 &lt;= var2<br>
var2 &lt;= 5
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
</TABLE>

<TABLE>
  <TR>
    <TD><A HREF="#1008419"><SUP>1</SUP></A><a name="1008418"> </a>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
These examples assume that <FONT FACE="courier, couriernew, monospaced size">var1</FONT> has been assigned the value 3 and <FONT FACE="courier, couriernew, monospaced size">var2</FONT> has been assigned the value 4.
</FONT>
<P>
</TD>
  </TR>
</TABLE>


<P>
</FONT>
<P>

<P>
<BR>
<A NAME="1008458"> </A>
<A NAME="Arithmetic Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>Arithmetic Operators</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008459"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/). These operators work as they do in most other programming languages, except the / operator returns a floating-point division in JavaScript, not a truncated division as it does in languages such as C or Java. For example:</zparagraph>
</FONT>
<P>
<A NAME="1012547"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>1/2 //returns 0.5 in JavaScript<br>
1/2 //returns 0 in Java
</zcodeline>
</FONT>
<P>
<A NAME="1008502"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>In addition, JavaScript provides the arithmetic operators listed in the following table.</zparagraph>
</FONT>
<P>

<P>
<A NAME="1010137"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<BR>
<P>
<TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0">
  <CAPTION></CAPTION><P><FONT FACE=""><B>
<A NAME="1008466"> </A>
<A NAME="Arithmetic Operators"> </A>
<ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablecaption>Table 3.3&#32;&nbsp&nbsp Arithmetic Operators</ztablecaption>
</B>
</FONT>
</B></FONT>
<BR>
<BR>
  <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008472"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Operator</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008474"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Description</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008476"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Example</ztablehead>
</B>
</FONT>
</TH>
  </DIV></TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1008478"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext><FONT FACE="courier, couriernew, monospaced size">%<br></FONT>(Modulus)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008480"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Binary operator. Returns the integer remainder of dividing the two operands.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008482"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext> 12 % 5 returns 2.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1008484"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext><FONT FACE="courier, couriernew, monospaced size">++</FONT> <br>(Increment)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008486"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Unary operator. Adds one to its operand. If used as a prefix operator (<FONT FACE="courier, couriernew, monospaced size">++x</FONT>), returns the value of its operand after adding one; if used as a postfix operator (<FONT FACE="courier, couriernew, monospaced size">x++</FONT>), returns the value of its operand before adding one.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008488"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>If <FONT FACE="courier, couriernew, monospaced size">x</FONT> is 3, then <FONT FACE="courier, couriernew, monospaced size">++x</FONT> sets <FONT FACE="courier, couriernew, monospaced size">x</FONT> to 4 and returns 4, whereas <FONT FACE="courier, couriernew, monospaced size">x++</FONT> sets <FONT FACE="courier, couriernew, monospaced size">x</FONT> to 4 and returns 3.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1008490"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext><FONT FACE="courier, couriernew, monospaced size">--</FONT> <br>(Decrement)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008492"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Unary operator. Subtracts one to its operand. The return value is analogous to that for the increment operator.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008494"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>If <FONT FACE="courier, couriernew, monospaced size">x</FONT> is 3, then <FONT FACE="courier, couriernew, monospaced size">--x</FONT> sets <FONT FACE="courier, couriernew, monospaced size">x</FONT> to 2 and returns 2, whereas <FONT FACE="courier, couriernew, monospaced size">x++</FONT> sets <FONT FACE="courier, couriernew, monospaced size">x</FONT> to 2 and returns 3.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1008496"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext><FONT FACE="courier, couriernew, monospaced size">-</FONT> <br>(Unary negation)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008498"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Unary operator. Returns the negation of its operand.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008500"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>If <FONT FACE="courier, couriernew, monospaced size">x</FONT> is 3, then <FONT FACE="courier, couriernew, monospaced size">-x</FONT> returns -3.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
</TABLE>



<P>
</FONT>
<P>

<P>
<BR>
<A NAME="1008505"> </A>
<A NAME="Bitwise Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>Bitwise Operators</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008506"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Bitwise operators treat their operands as a set of 32 bits (zeros and ones), rather than as decimal, hexadecimal, or octal numbers. For example, the decimal number nine has a binary representation of 1001. Bitwise operators perform their operations on such binary representations, but they return standard JavaScript numerical values.</zparagraph>
</FONT>
<P>

<A NAME="1008566"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following table summarizes JavaScript's bitwise operators.</zparagraph>
</FONT>
<P>

<P>
<A NAME="1010164"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<BR>
<P>
<TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0">
  <CAPTION></CAPTION><P><FONT FACE=""><B>
<A NAME="1008509"> </A>
<A NAME="Bitwise operators"> </A>
<ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablecaption>Table 3.4&#32;&nbsp&nbsp Bitwise operators</ztablecaption>
</B>
</FONT>
</B></FONT>
<BR>
<BR>
  <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008515"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Operator</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008517"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Usage</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008519"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Description</ztablehead>
</B>
</FONT>
</TH>
  </DIV></TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011933"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Bitwise AND</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1011953"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>a</I> &amp; <I>b
</I></zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008526"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns a one in each bit position for which the corresponding bits of both operands are ones.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011936"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Bitwise OR</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1011955"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>a</I> | <I>b
</I></zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008533"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns a one in each bit position for which the corresponding bits of either or both operands are ones.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011939"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Bitwise XOR</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1011957"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>a</I> ^ <I>b
</I></zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1012591"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Returns a one in each bit position for which the corresponding bits of either but not both operands are ones.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011942"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Bitwise NOT</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1011959"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>~ <I>a
</I></zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008547"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Inverts the bits of its operand.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011945"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Left shift</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1011961"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>a</I> &lt;&lt; <I>b
</I></zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008553"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Shifts <FONT FACE="courier, couriernew, monospaced size">a</FONT> in binary representation <FONT FACE="courier, couriernew, monospaced size">b</FONT> bits to left, shifting in zeros from the right.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011947"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Sign-propagating right shift</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1011963"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>a</I> &gt;&gt; <I>b
</I></zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008559"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Shifts <FONT FACE="courier, couriernew, monospaced size">a</FONT> in binary representation <FONT FACE="courier, couriernew, monospaced size">b</FONT> bits to right, discarding bits shifted off.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1011951"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Zero-fill right shift</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1011965"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>a</I> &gt;&gt;&gt; <I>b
</I></zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008565"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>Shifts <FONT FACE="courier, couriernew, monospaced size">a</FONT> in binary representation <FONT FACE="courier, couriernew, monospaced size">b</FONT> bits to the right, discarding bits shifted off, and shifting in zeros from the left.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
</TABLE>



<P>
</FONT>
<P>

<BR>
<P>
<A NAME="1008568"> </A>
<A NAME="Bitwise Logical Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>Bitwise Logical Operators</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1008569"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Conceptually, the bitwise logical operators work as follows:</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1008570"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>The operands are converted to thirty-two-bit integers and expressed by a series of bits (zeros and ones).</zsmartlist1>
</FONT>
<P><A NAME="1008571"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>Each bit in the first operand is paired with the corresponding bit in the second operand: first bit to first bit, second bit to second bit, and so on.</zsmartlist1>
</FONT>
<P><A NAME="1008572"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>The operator is applied to each pair of bits, and the result is constructed bitwise.</zsmartlist1>
</FONT>
<P></ul>

<A NAME="1008573"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For example, the binary representation of nine is 1001, and the binary representation of fifteen is 1111. So, when the bitwise operators are applied to these values, the results are as follows:</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1008574"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>15 &amp; 9 yields 9 (1111 &amp; 1001 = 1001)</zsmartlist1>
</FONT>
<P><A NAME="1008575"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>15 | 9 yields 15 (1111 | 1001 = 1111)</zsmartlist1>
</FONT>
<P><A NAME="1008576"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1>15 ^ 9 yields 6 (1111 ^ 1001 = 0110)</zsmartlist1>
</FONT>
<P></ul>
<BR>
<P>
<A NAME="1008578"> </A>
<A NAME="Bitwise Shift Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>Bitwise Shift Operators</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1008579"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The bitwise shift operators take two operands: the first is a quantity to be shifted, and the second specifies the number of bit positions by which the first operand is to be shifted. The direction of the shift operation is controlled by the operator used.</zparagraph>
</FONT>
<P>

<A NAME="1008580"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Shift operators convert their operands to thirty-two-bit integers and return a result of the same type as the left operator.</zparagraph>
</FONT>
<P>

<A NAME="1008619"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The shift operators are listed in the following table.</zparagraph>
</FONT>
<P>

<P>
<A NAME="1010171"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<BR>
<P>
<TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0">
  <CAPTION></CAPTION><P><FONT FACE=""><B>
<A NAME="1008587"> </A>
<A NAME="Bitwise shift operators"> </A>
<ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablecaption>Table 3.5&#32;&nbsp&nbsp Bitwise shift operators</ztablecaption>
</B>
</FONT>
</B></FONT>
<BR>
<BR>
  <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008593"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Operator</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008595"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Description</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1008597"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Example</ztablehead>
</B>
</FONT>
</TH>
  </DIV></TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1008600"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext><FONT FACE="courier, couriernew, monospaced size">&lt;&lt;</FONT> <br>(Left shift)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008602"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008604"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext><FONT FACE="courier, couriernew, monospaced size">9&lt;&lt;2</FONT> yields 36, because 1001 shifted 2 bits to the left becomes 100100, which is 36.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1008606"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext><FONT FACE="courier, couriernew, monospaced size">&gt;&gt;</FONT> <br>(Sign-propagating right shift)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008609"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008611"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>9&gt;&gt;2 yields 2, because 1001 shifted 2 bits to the right becomes 10, which is 2. Likewise, -9&gt;&gt;2 yields -3, because the sign is preserved.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1008613"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext><FONT FACE="courier, couriernew, monospaced size">&gt;&gt;&gt;</FONT> <br>(Zero-fill right shift)</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008615"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left.</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1008617"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>19&gt;&gt;&gt;2 yields 4, because 10011 shifted 2 bits to the right becomes 100, which is 4. For non-negative numbers, zero-fill right shift and sign-propagating right shift yield the same result.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
</TABLE>



<P>
</FONT>
<P>

<P>
<BR>
<A NAME="1008622"> </A>
<A NAME="Logical Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>Logical Operators</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008623"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value. However, the &amp;&amp; and || operators actually return the value of one of the specified operands, so if these operators are used with non-Boolean values, they may return a non-Boolean value. The logical operators are described in the following table.</zparagraph>
</FONT>
<P>

<P>
<A NAME="1010198"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<BR>
<P>
<TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0">
  <CAPTION></CAPTION><P><FONT FACE=""><B>
<A NAME="1012818"> </A>
<A NAME="Logical operators"> </A>
<ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablecaption>Table 3.6&#32;&nbsp&nbsp Logical operators</ztablecaption>
</B>
</FONT>
</B></FONT>
<BR>
<BR>
  <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1012824"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Operator</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1012826"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Usage</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1012828"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Description</ztablehead>
</B>
</FONT>
</TH>
  </DIV></TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012831"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>&amp;&amp;</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012833"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>expr1 &amp;&amp; expr2
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1012877"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>(Logical AND) Returns <FONT FACE="courier, couriernew, monospaced size">expr1</FONT> if it can be converted to false; otherwise, returns <FONT FACE="courier, couriernew, monospaced size">expr2</FONT>. Thus, when used with Boolean values, &amp;&amp; returns true if both operands are true; otherwise, returns false.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012840"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>||</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012842"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>expr1 || expr2
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1012879"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>(Logical OR) Returns <FONT FACE="courier, couriernew, monospaced size">expr1</FONT> if it can be converted to true; otherwise, returns <FONT FACE="courier, couriernew, monospaced size">expr2</FONT>. Thus, when used with Boolean values, || returns true if either operand is true; if both are false, returns false.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012849"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>! </ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012851"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>!expr
</zcodeline>
</FONT>
<P>&nbsp;</TD>
    <TD VALIGN=TOP>
<P>
<A NAME="1012881"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>(Logical NOT) Returns false if its single operand can be converted to true; otherwise, returns true.</ztabletext>
</FONT>&nbsp;</TD>
  </TR>
</TABLE>



<P>
</FONT>
<P>


<A NAME="1012872"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Examples of expressions that can be converted to false are those that evaluate to null, 0, the empty string (""), or undefined.</zparagraph>
</FONT>
<P>

<A NAME="1012887"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following code shows examples of the &amp;&amp; (logical AND) operator.</zparagraph>
</FONT>
<P>
<A NAME="1012888"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>a1=true &amp;&amp; true &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// t &amp;&amp; t returns true<br>
a2=true &amp;&amp; false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// t &amp;&amp; f returns false<br>
a3=false &amp;&amp; true &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// f &amp;&amp; t returns false<br>
a4=false &amp;&amp; (3 == 4) &nbsp;// f &amp;&amp; f returns false<br>
a5="Cat" &amp;&amp; "Dog" &nbsp;&nbsp;&nbsp;&nbsp;// t &amp;&amp; t returns Dog<br>
a6=false &amp;&amp; "Cat" &nbsp;&nbsp;&nbsp;&nbsp;// f &amp;&amp; t returns false<br>
a7="Cat" &amp;&amp; false &nbsp;&nbsp;&nbsp;&nbsp;// t &amp;&amp; f returns false
</zcodeline>
</FONT>
<P>
<A NAME="1012889"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following code shows examples of the || (logical OR) operator.</zparagraph>
</FONT>
<P>
<A NAME="1012890"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>o1=true || true &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// t || t returns true<br>
o2=false || true &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// f || t returns true<br>
o3=true || false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// t || f returns true<br>
o4=false || (3 == 4) &nbsp;// f || f returns false<br>
o5="Cat" || "Dog" &nbsp;&nbsp;&nbsp;&nbsp;// t || t returns Cat<br>
o6=false || "Cat" &nbsp;&nbsp;&nbsp;&nbsp;// f || t returns Cat<br>
o7="Cat" || false &nbsp;&nbsp;&nbsp;&nbsp;// t || f returns Cat
</zcodeline>
</FONT>
<P>
<A NAME="1012891"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following code shows examples of the ! (logical NOT) operator.</zparagraph>
</FONT>
<P>
<A NAME="1012892"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>n1=!true &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// !t returns false<br>
n2=!false &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// !f returns true<br>
n3=!"Cat" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// !t returns false
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1008676"> </A>
<A NAME="Short-Circuit Evaluation"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>Short-Circuit Evaluation</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1008677"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>As logical expressions are evaluated left to right, they are tested for possible "short-circuit" evaluation using the following rules:</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1008678"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><FONT FACE="courier, couriernew, monospaced size">false</FONT> &amp;&amp; <I>anything</I> is short-circuit evaluated to false.</zsmartlist1>
</FONT>
<P><A NAME="1008679"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><FONT FACE="courier, couriernew, monospaced size">true</FONT> || <I>anything</I> is short-circuit evaluated to true.</zsmartlist1>
</FONT>
<P></ul>

<A NAME="1008680"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The rules of logic guarantee that these evaluations are always correct. Note that the <I>anything</I> part of the above expressions is not evaluated, so any side effects of doing so do not take effect.</zparagraph>
</FONT>
<P>
<P>
<BR>
<A NAME="1008684"> </A>
<A NAME="String Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>String Operators</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008685"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>In addition to the comparison operators, which can be used on string values, the concatenation operator (+) concatenates two string values together, returning another string that is the union of the two operand strings. For example, <FONT FACE="courier, couriernew, monospaced size">"my&nbsp;"&nbsp;+&nbsp;"string"</FONT> returns the string <FONT FACE="courier, couriernew, monospaced size">"my&nbsp;string"</FONT>.</zparagraph>
</FONT>
<P>

<A NAME="1008686"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The shorthand assignment operator += can also be used to concatenate strings. For example, if the variable <FONT FACE="courier, couriernew, monospaced size">mystring</FONT> has the value "alpha," then the expression <FONT FACE="courier, couriernew, monospaced size">mystring&nbsp;+=&nbsp;"bet"</FONT> evaluates to "alphabet" and assigns this value to <FONT FACE="courier, couriernew, monospaced size">mystring</FONT>.</zparagraph>
</FONT>
<P>
<P>
<BR>
<A NAME="1008688"> </A>
<A NAME="Special Operators"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>Special Operators</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1012006"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>JavaScript provides the following special operators:</zparagraph>
</FONT>
<P>
<ul>
<A NAME="1012007"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008690"  >conditional operator</A></zsmartlist1>
</FONT>
<P><A NAME="1012015"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008698"  >comma operator</A></zsmartlist1>
</FONT>
<P><A NAME="1012016"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008702"  >delete</A></zsmartlist1>
</FONT>
<P><A NAME="1012318"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1012255"  >in</A></zsmartlist1>
</FONT>
<P><A NAME="1012033"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1012225"  >instanceof</A></zsmartlist1>
</FONT>
<P><A NAME="1012155"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1010464"  >new</A></zsmartlist1>
</FONT>
<P><A NAME="1012034"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1010302"  >this</A></zsmartlist1>
</FONT>
<P><A NAME="1012051"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1008719"  >typeof</A></zsmartlist1>
</FONT>
<P><A NAME="1012052"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>  <li></B>
<zsmartlist1><A HREF="expr.html#1012081"  >void</A></zsmartlist1>
</FONT>
<P></ul>
<BR>
<P>
<A NAME="1008690"> </A>
<A NAME="conditional operator"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>conditional operator</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1008691"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The conditional operator is the only JavaScript operator that takes three operands. The operator can have one of two values based on a condition. The syntax is:</zparagraph>
</FONT>
<P>
<A NAME="1008693"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>condition</I> ? <I>val1</I> : <I>val2
</I></zcodeline>
</FONT>
<P>
<A NAME="1008694"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>If <FONT FACE="courier, couriernew, monospaced size">condition</FONT> is true, the operator has the value of <FONT FACE="courier, couriernew, monospaced size">val1</FONT>. Otherwise it has the value of <FONT FACE="courier, couriernew, monospaced size">val2</FONT>. You can use the conditional operator anywhere you would use a standard operator.</zparagraph>
</FONT>
<P>

<A NAME="1008695"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For example,</zparagraph>
</FONT>
<P>
<A NAME="1008696"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>status = (age &gt;= 18) ? "adult" : "minor"
</zcodeline>
</FONT>
<P>
<A NAME="1008697"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>This statement assigns the value "adult" to the variable <FONT FACE="courier, couriernew, monospaced size">status</FONT> if <FONT FACE="courier, couriernew, monospaced size">age</FONT> is eighteen or more. Otherwise, it assigns the value "minor" to <FONT FACE="courier, couriernew, monospaced size">status</FONT>.</zparagraph>
</FONT>
<P>
<BR>
<P>
<A NAME="1008698"> </A>
<A NAME="comma operator"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>comma operator</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1008699"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The comma operator (<FONT FACE="courier, couriernew, monospaced size">,</FONT>) simply evaluates both of its operands and returns the value of the second operand. This operator is primarily used inside a <FONT FACE="courier, couriernew, monospaced size">for</FONT> loop, to allow multiple variables to be updated each time through the loop.</zparagraph>
</FONT>
<P>

<A NAME="1008700"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For example, if <FONT FACE="courier, couriernew, monospaced size">a</FONT> is a 2-dimensional array with 10 elements on a side, the following code uses the comma operator to increment two variables at once. The code prints the values of the diagonal elements in the array:</zparagraph>
</FONT>
<P>
<A NAME="1008701"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>for (var i=0, j=9; i &lt;= 9; i++, j--)<br>
&nbsp;&nbsp;&nbsp;document.writeln("a["+i+","+j+"]= " + a[i*10 +j])
</zcodeline>
</FONT>
<P>
<A NAME="1013217"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Note that two-dimensional arrays are not yet supported. This example emulates a two-dimensional array using a one-dimensional array.</zparagraph>
</FONT>
<P>
<BR>
<P>
<A NAME="1008702"> </A>
<A NAME="delete"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>delete</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1008703"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The delete operator deletes an object, an object's property, or an element at a specified index in an array. The syntax is:</zparagraph>
</FONT>
<P>
<A NAME="1012179"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>delete <I>objectName<br>
</I>delete <I>objectName</I>.<I>property<br>
</I>delete <I>objectName</I>[<I>index</I>]<br>
delete <I>property</I> // legal only within a with statement
</zcodeline>
</FONT>
<P>
<A NAME="1010461"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>where <FONT FACE="courier, couriernew, monospaced size">objectName</FONT> is the name of an object, <FONT FACE="courier, couriernew, monospaced size">property</FONT> is an existing property, and <FONT FACE="courier, couriernew, monospaced size">index</FONT> is an integer representing the location of an element in an array.</zparagraph>
</FONT>
<P>

<A NAME="1012192"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The fourth form is legal only within a <FONT FACE="courier, couriernew, monospaced size">with</FONT> statement, to delete a property from an object.</zparagraph>
</FONT>
<P>

<A NAME="1012193"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You can use the <FONT FACE="courier, couriernew, monospaced size">delete</FONT> operator to delete variables declared implicitly but not those declared with the <FONT FACE="courier, couriernew, monospaced size">var</FONT> statement.</zparagraph>
</FONT>
<P>

<A NAME="1012221"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>If the <FONT FACE="courier, couriernew, monospaced size">delete</FONT> operator succeeds, it sets the property or element to <FONT FACE="courier, couriernew, monospaced size">undefined. The delete</FONT> operator returns true if the operation is possible; it returns false if the operation is not possible.</zparagraph>
</FONT>
<P>
<A NAME="1012222"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>x=42<br>
var y= 43<br>
myobj=new Number()<br>
myobj.h=4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// create property h<br>
delete x &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// returns true (can delete if declared implicitly)<br>
delete y &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// returns false (cannot delete if declared with var)<br>
delete Math.PI // returns false (cannot delete predefined properties)<br>
delete myobj.h // returns true (can delete user-defined properties)<br>
delete myobj &nbsp;&nbsp;// returns true (can delete if declared implicitly)
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1012230"> </A>
<A NAME="Deleting array elements"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<zhead4>Deleting array elements</zhead4>
</B>
</FONT>
<BR>

<A NAME="1012231"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>When you delete an array element, the array length is not affected. For example, if you delete a[3], a[4] is still a[4] and a[3] is undefined.</zparagraph>
</FONT>
<P>

<A NAME="1012232"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>When the <FONT FACE="courier, couriernew, monospaced size">delete</FONT> operator removes an array element, that element is no longer in the array. In the following example, trees[3] is removed with <FONT FACE="courier, couriernew, monospaced size">delete</FONT>.</zparagraph>
</FONT>
<P>
<A NAME="1012233"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>trees=new Array("redwood","bay","cedar","oak","maple")<br>
delete trees[3]<br>
if (3 in trees) {<br>
&nbsp;&nbsp;&nbsp;// this does not get executed<br>
}
</zcodeline>
</FONT>
<P>
<A NAME="1012234"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>If you want an array element to exist but have an undefined value, use the <FONT FACE="courier, couriernew, monospaced size">undefined</FONT> keyword instead of the <FONT FACE="courier, couriernew, monospaced size">delete</FONT> operator. In the following example, trees[3] is assigned the value undefined, but the array element still exists:</zparagraph>
</FONT>
<P>
<A NAME="1012235"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>trees=new Array("redwood","bay","cedar","oak","maple")<br>
trees[3]=undefined<br>
if (3 in trees) {<br>
&nbsp;&nbsp;&nbsp;// this gets executed<br>
}
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1012255"> </A>
<A NAME="in"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>in</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1012268"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">in</FONT> operator returns true if the specified property is in the specified object. The syntax is:</zparagraph>
</FONT>
<P>
<A NAME="1012275"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>propNameOrNumber</I> in <I>objectName
</I></zcodeline>
</FONT>
<P>
<A NAME="1012270"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>where <FONT FACE="courier, couriernew, monospaced size">propNameOrNumber</FONT> is a string or numeric expression representing a property name or array index, and <FONT FACE="courier, couriernew, monospaced size">objectName</FONT> is the name of an object.</zparagraph>
</FONT>
<P>

<A NAME="1012323"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following examples show some uses of the <FONT FACE="courier, couriernew, monospaced size">in</FONT> operator.</zparagraph>
</FONT>
<P>
<A NAME="1012324"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>// Arrays<br>
trees=new Array("redwood","bay","cedar","oak","maple")<br>
0 in trees&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// returns true<br>
3 in trees&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// returns true<br>
6 in trees&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// returns false<br>
"bay" in trees&nbsp;&nbsp;&nbsp;&nbsp;// returns false (you must specify the index number,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// not the value at that index)<br>
"length" in trees // returns true (length is an Array property)
</zcodeline>
</FONT>
<P><A NAME="1012325"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>// Predefined objects<br>
"PI" in Math&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// returns true<br>
myString=new String("coral")<br>
"length" in myString&nbsp;&nbsp;// returns true
</zcodeline>
</FONT>
<P><A NAME="1012326"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>// Custom objects<br>
mycar = {make:"Honda",model:"Accord",year:1998}<br>
"make" in mycar&nbsp;&nbsp;// returns true<br>
"model" in mycar // returns true
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1012225"> </A>
<A NAME="instanceof"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>instanceof</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1012226"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">instanceof</FONT> operator returns true if the specified object is of the specified object type. The syntax is:</zparagraph>
</FONT>
<P>
<A NAME="1012125"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>objectName</I> instanceof <I>objectType
</I></zcodeline>
</FONT>
<P>
<A NAME="1012126"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>where <FONT FACE="courier, couriernew, monospaced size">objectName</FONT> is the name of the object to compare to <FONT FACE="courier, couriernew, monospaced size">objectType</FONT>, and <FONT FACE="courier, couriernew, monospaced size">objectType</FONT> is an object type, such as Date or Array.</zparagraph>
</FONT>
<P>

<A NAME="1012336"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Use <FONT FACE="courier, couriernew, monospaced size">instanceof</FONT> when you need to confirm the type of an object at runtime. For example, when catching exceptions, you can branch to different exception-handling code depending on the type of exception thrown.</zparagraph>
</FONT>
<P>

<A NAME="1012145"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For example, the following code uses <FONT FACE="courier, couriernew, monospaced size">instanceof</FONT> to determine whether <FONT FACE="courier, couriernew, monospaced size">theDay</FONT> is a <FONT FACE="courier, couriernew, monospaced size">Date</FONT> object. Because <FONT FACE="courier, couriernew, monospaced size">theDay</FONT> is a <FONT FACE="courier, couriernew, monospaced size">Date</FONT> object, the statements in the <FONT FACE="courier, couriernew, monospaced size">if</FONT> statement execute.</zparagraph>
</FONT>
<P>
<A NAME="1012146"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>theDay=new Date(1995, 12, 17)<br>
if (theDay instanceof Date) {<br>
&nbsp;&nbsp;&nbsp;// statements to execute<br>
}
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1010464"> </A>
<A NAME="new"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>new</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1010465"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You can use the <FONT FACE="courier, couriernew, monospaced size">new</FONT> operator to create an instance of a user-defined object type or of one of the predefined object types <FONT FACE="courier, couriernew, monospaced size">Array</FONT>, <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT>, <FONT FACE="courier, couriernew, monospaced size">Date</FONT>, <FONT FACE="courier, couriernew, monospaced size">Function</FONT>, <FONT FACE="courier, couriernew, monospaced size">Image</FONT>, <FONT FACE="courier, couriernew, monospaced size">Number</FONT>, <FONT FACE="courier, couriernew, monospaced size">Object</FONT>, <FONT FACE="courier, couriernew, monospaced size">Option</FONT>, <FONT FACE="courier, couriernew, monospaced size">RegExp</FONT>, or <FONT FACE="courier, couriernew, monospaced size">String</FONT>. On the server, you can also use it with <FONT FACE="courier, couriernew, monospaced size">DbPool</FONT>, <FONT FACE="courier, couriernew, monospaced size">Lock</FONT>, <FONT FACE="courier, couriernew, monospaced size">File</FONT>, or <FONT FACE="courier, couriernew, monospaced size">SendMail</FONT>. Use <FONT FACE="courier, couriernew, monospaced size">new</FONT> as follows:</zparagraph>
</FONT>
<P>
<A NAME="1008710"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline><I>objectName</I> = new <I>objectType</I> ( <I>param1</I> [,<I>param2</I>] ...[,<I>paramN</I>] )
</zcodeline>
</FONT>
<P>
<A NAME="1010290"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You can also create objects using object initializers, as described in <A HREF="obj.html#1008330"  >"Using Object Initializers" on page&nbsp;93</A>.</zparagraph>
</FONT>
<P>

<A NAME="1009819"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>See <FONT FACE="courier, couriernew, monospaced size">new</FONT> in the <A HREF="http://developer.netscape.com/docs/manuals/js/core/jsref/index.htm"><I>Core JavaScript Reference</I></A> for more information.</zparagraph>
</FONT>
<P>
<BR>
<P>
<A NAME="1010302"> </A>
<A NAME="this"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>this</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1010303"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Use the <FONT FACE="courier, couriernew, monospaced size">this</FONT> keyword to refer to the current object. In general, <FONT FACE="courier, couriernew, monospaced size">this</FONT> refers to the calling object in a method. Use <FONT FACE="courier, couriernew, monospaced size">this</FONT> as follows:</zparagraph>
</FONT>
<P>
<A NAME="1010304"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>this[.<I>propertyName</I>]
</zcodeline>
</FONT>
<P>
<A NAME="1010305"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example 1.</B> Suppose a function called <FONT FACE="courier, couriernew, monospaced size">validate</FONT> validates an object's <FONT FACE="courier, couriernew, monospaced size">value</FONT> property, given the object and the high and low values:</zparagraph>
</FONT>
<P>
<A NAME="1010306"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>function validate(obj, lowval, hival) {<br>
&nbsp;&nbsp;&nbsp;if ((obj.value &lt; lowval) || (obj.value &gt; hival))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert("Invalid Value!")<br>
}
</zcodeline>
</FONT>
<P>
<A NAME="1010307"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You could call <FONT FACE="courier, couriernew, monospaced size">validate</FONT> in each form element's <FONT FACE="courier, couriernew, monospaced size">onChange</FONT> event handler, using <FONT FACE="courier, couriernew, monospaced size">this</FONT> to pass it the form element, as in the following example:</zparagraph>
</FONT>
<P>
<A NAME="1010308"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&lt;B&gt;Enter a number between 18 and 99:&lt;/B&gt;<br>
&lt;INPUT TYPE = "text" NAME = "age" SIZE = 3<br>
&nbsp;&nbsp;&nbsp;onChange="validate(this, 18, 99)"&gt;
</zcodeline>
</FONT>
<P>
<A NAME="1010309"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><B>Example 2.</B> When combined with the <FONT FACE="courier, couriernew, monospaced size">form</FONT> property, <FONT FACE="courier, couriernew, monospaced size">this</FONT> can refer to the current object's parent form. In the following example, the form <FONT FACE="courier, couriernew, monospaced size">myForm</FONT> contains a <FONT FACE="courier, couriernew, monospaced size">Text</FONT> object and a button. When the user clicks the button, the value of the <FONT FACE="courier, couriernew, monospaced size">Text</FONT> object is set to the form's name. The button's <FONT FACE="courier, couriernew, monospaced size">onClick</FONT> event handler uses <FONT FACE="courier, couriernew, monospaced size">this.form</FONT> to refer to the parent form, <FONT FACE="courier, couriernew, monospaced size">myForm</FONT>.</zparagraph>
</FONT>
<P>
<A NAME="1010310"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&lt;FORM NAME="myForm"&gt;<br>
Form name:&lt;INPUT TYPE="text" NAME="text1" VALUE="Beluga"&gt;<br>
&lt;P&gt;<br>
&lt;INPUT NAME="button1" TYPE="button" VALUE="Show Form Name"<br>
&nbsp;&nbsp;&nbsp;onClick="this.form.text1.value=this.form.name"&gt;<br>
&lt;/FORM&gt;
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1008719"> </A>
<A NAME="typeof"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>typeof</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1008720"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">typeof</FONT> operator is used in either of the following ways:</zparagraph>
</FONT>
<P>
<A NAME="1008721"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>1. typeof <I>operand<br>
</I>2. typeof (<I>operand</I>)
</zcodeline>
</FONT>
<P>
<A NAME="1008722"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">typeof</FONT> operator returns a string indicating the type of the unevaluated operand. <FONT FACE="courier, couriernew, monospaced size">operand</FONT> is the string, variable, keyword, or object for which the type is to be returned. The parentheses are optional.</zparagraph>
</FONT>
<P>

<A NAME="1008723"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Suppose you define the following variables:</zparagraph>
</FONT>
<P>
<A NAME="1008724"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>var myFun = new Function("5+2")<br>
var shape="round"<br>
var size=1<br>
var today=new Date()
</zcodeline>
</FONT>
<P>
<A NAME="1008725"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">typeof</FONT> operator returns the following results for these variables:</zparagraph>
</FONT>
<P>
<A NAME="1008726"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>typeof myFun is function<br>
typeof shape is string<br>
typeof size is number<br>
typeof today is object<br>
typeof dontExist is undefined
</zcodeline>
</FONT>
<P>
<A NAME="1008727"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For the keywords <FONT FACE="courier, couriernew, monospaced size">true</FONT> and <FONT FACE="courier, couriernew, monospaced size">null</FONT>, the <FONT FACE="courier, couriernew, monospaced size">typeof</FONT> operator returns the following results:</zparagraph>
</FONT>
<P>
<A NAME="1008728"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>typeof true is boolean<br>
typeof null is object
</zcodeline>
</FONT>
<P>
<A NAME="1008729"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For a number or string, the <FONT FACE="courier, couriernew, monospaced size">typeof</FONT> operator returns the following results:</zparagraph>
</FONT>
<P>
<A NAME="1008730"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>typeof 62 is number<br>
typeof 'Hello world' is string
</zcodeline>
</FONT>
<P>
<A NAME="1008731"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For property values, the <FONT FACE="courier, couriernew, monospaced size">typeof</FONT> operator returns the type of value the property contains:</zparagraph>
</FONT>
<P>
<A NAME="1008732"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>typeof document.lastModified is string<br>
typeof window.length is number<br>
typeof Math.LN2 is number
</zcodeline>
</FONT>
<P>
<A NAME="1008733"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For methods and functions, the <FONT FACE="courier, couriernew, monospaced size">typeof</FONT> operator returns results as follows:</zparagraph>
</FONT>
<P>
<A NAME="1008734"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>typeof blur is function<br>
typeof eval is function<br>
typeof parseInt is function<br>
typeof shape.split is function
</zcodeline>
</FONT>
<P>
<A NAME="1008735"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>For predefined objects, the <FONT FACE="courier, couriernew, monospaced size">typeof</FONT> operator returns results as follows:</zparagraph>
</FONT>
<P>
<A NAME="1012078"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>typeof Date is function<br>
typeof Function is function<br>
typeof Math is function<br>
typeof Option is function<br>
typeof String is function
</zcodeline>
</FONT>
<P><BR>
<P>
<A NAME="1012081"> </A>
<A NAME="void"> </A>
<FONT FACE="Arial, Helvetica, sans-serif">
<B>
<zhead3>void</zhead3>
</B>
</FONT>
<BR>
<BR>

<A NAME="1012082"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The void operator is used in either of the following ways:</zparagraph>
</FONT>
<P>
<A NAME="1008741"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>1. void (<I>expression</I>)<br>
2. void <I>expression
</I></zcodeline>
</FONT>
<P>
<A NAME="1008742"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The void operator specifies an expression to be evaluated without returning a value. <FONT FACE="courier, couriernew, monospaced size">expression</FONT> is a JavaScript expression to evaluate. The parentheses surrounding the expression are optional, but it is good style to use them.</zparagraph>
</FONT>
<P>

<A NAME="1008743"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>You can use the <FONT FACE="courier, couriernew, monospaced size">void</FONT> operator to specify an expression as a hypertext link. The expression is evaluated but is not loaded in place of the current document.</zparagraph>
</FONT>
<P>

<A NAME="1008744"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following code creates a hypertext link that does nothing when the user clicks it. When the user clicks the link, <FONT FACE="courier, couriernew, monospaced size">void(0)</FONT> evaluates to undefined, which has no effect in JavaScript.</zparagraph>
</FONT>
<P>
<A NAME="1008745"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&lt;A HREF="javascript:void(0)"&gt;Click here to do nothing&lt;/A&gt;
</zcodeline>
</FONT>
<P>
<A NAME="1008746"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following code creates a hypertext link that submits a form when the user clicks it.</zparagraph>
</FONT>
<P>
<A NAME="1008747"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&lt;A HREF="javascript:void(document.form.submit())"&gt;<br>
Click here to submit&lt;/A&gt;
</zcodeline>
</FONT>
<P><P>
<BR>
<A NAME="1008750"> </A>
<A NAME="Operator Precedence"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="4">
<zhead2>Operator Precedence</zhead2>
</FONT>
<BR>
<BR>



<A NAME="1008751"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <I>precedence</I> of operators determines the order they are applied when evaluating an expression. You can override operator precedence by using parentheses.</zparagraph>
</FONT>
<P>

<A NAME="1008825"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following table describes the precedence of operators, from lowest to highest.</zparagraph>
</FONT>
<P>

<P>
<A NAME="1010207"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<BR>
<P>
<TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0">
  <CAPTION></CAPTION><P><FONT FACE=""><B>
<A NAME="1012364"> </A>
<A NAME="Operator precedence &nbsp;"> </A>
<ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablecaption>Table 3.7&#32;&nbsp&nbsp Operator precedence &nbsp;</ztablecaption>
</B>
</FONT>
</B></FONT>
<BR>
<BR>
  <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1012368"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Operator type</ztablehead>
</B>
</FONT>
</TH>
    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1012370"> </A>
<P ALIGN="LEFT">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<B>
<ztablehead>Individual operators</ztablehead>
</B>
</FONT>
</TH>
  </DIV></TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012465"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>comma</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012467"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>,
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012372"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>assignment</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012374"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>= += -= *= /= %= &lt;&lt;= &gt;&gt;= &gt;&gt;&gt;= &amp;= ^= |=
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012376"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>conditional</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012378"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>?:
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012380"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>logical-or</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012382"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>||
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012384"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>logical-and</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012386"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&amp;&amp;
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012388"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>bitwise-or</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012390"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>|
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012392"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>bitwise-xor</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012394"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>^
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012396"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>bitwise-and</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012398"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&amp;
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012400"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>equality</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012402"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>== != === !==
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012404"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>relational</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012406"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&lt; &lt;= &gt; &gt;= in instanceof
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012408"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>bitwise shift</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012410"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>&lt;&lt; &gt;&gt; &gt;&gt;&gt;
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012412"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>addition/subtraction</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012414"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>+ -
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012416"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>multiply/divide</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012418"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>* / %
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012420"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>negation/increment</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012422"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>! ~ - + ++ -- typeof void delete
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012471"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>call / create instance</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012473"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>() new
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
  <TR>
    <TD VALIGN=TOP>
<P>
<A NAME="1012424"> </A>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">
<ztabletext>member</ztabletext>
</FONT>&nbsp;</TD>
    <TD VALIGN=TOP><A NAME="1012426"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2">
<zcodeline>. []
</zcodeline>
</FONT>
<P>&nbsp;</TD>
  </TR>
</TABLE>



<P>
</FONT>
<P>




   </BLOCKQUOTE>
</BOOKCONTENT>

<FOOTERCONTENT>
   <BLOCKQUOTE>
 <BR>
            <b><a href="ident.html">
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Previous</a></FONT>&nbsp;&nbsp;&nbsp;&nbsp;</b>
<a href="contents.html">
<b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Contents</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="ix.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Index</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="regexp.html">
<b>
<FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">
Next
</a>
</FONT>
</b>&nbsp;&nbsp;&nbsp;&nbsp;
        <HR NOSHADE SIZE="1">


   <font face="Arial, Helvetica, sans-serif" SIZE="1">

Copyright &#169; 2000 <a href="http://www.netscape.com">Netscape Communications Corp.</a> All rights reserved.</FONT>
   </BLOCKQUOTE>
   <FONT FACE="Arial, Helvetica, sans-serif" SIZE="1">
   <P ALIGN="RIGHT">Last Updated <B>September 28, 2000</B>
   </FONT>
   <BR>

</FOOTERCONTENT>

</MAINCONTENT>

</BODY>


</HTML>